package com.wyd.tool;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class DBTableUtil {

	public static List<String> getTableNames(Connection conn, String DBName) throws SQLException {
		List<String> tablenames = new ArrayList<String>();
		ResultSet tableRet = null;
		try {
			if (conn == null) {
				return tablenames;
			}
			tableRet = conn.getMetaData().getTables(DBName, null, null, new String[] { "TABLE" });
			while (tableRet.next()) {
				tablenames.add(tableRet.getString("TABLE_NAME"));
			}
		} catch (Exception e) {
			// TODO: handle exception
		} finally {
			if (tableRet != null) {
				tableRet.close();
			}
		}
		return tablenames;
	}

}
